import axios from 'axios';
axios.defaults.timeout = 10000
const service = axios.create({
    baseURL: ''
})

export function GET(url, data) {
    return new Promise((resolve, reject) => {
        service.get(url, { params: data }).then((res) => {
            resolve(res)
        }).catch((err) => {
            reject(err)
        })
    })
}

export function POST(url, data) {
    return new Promise((resolve, reject) => {
        service.get(url, data, {
            headers: {
                "content-type": "application/json;charset=utf-8"
            }
        }).then((res) => {
            resolve(res)
        }).catch((err) => {
            reject(err)
        })
    })
}

service.interceptors.response.use((response)=>{
    return response.data
})

export default service